/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28463
 * Date: 2022—05—28
 * Time: 8:55
 */
public class Test02 {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        String s = "" ;
        for (int i = 0; i < 1_0000; ++i) {
            s += i;
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);

        start = System.currentTimeMillis();
        StringBuffer sbf = new StringBuffer("");
        for(int i = 0; i < 10000; ++i){
            sbf.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end - start);

        start = System.currentTimeMillis();
        StringBuilder sbd = new StringBuilder();
        for(int i = 0; i < 10000; ++i){ sbd.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end - start);
    }
    public static void main2(String[] args) {
        final char[] value = new char[] {'a','b','c'};
        value[0] = 'p';

        System.out.println("as");
            char[] ch = new char[]{'a', 'b', 'c'};
            String s1 = new String(ch); // s1对象并不在常量池中
            s1.intern();
            // s1.intern()；调用之后，会将s1对象的引用放入到常量池中
            String s2 = "abc"; // "abc" 在常量池中存在了，s2创建时直接用常量池中"abc"的引用
            System.out.println(s1 == s2);
    }
    public static void main1(String[] args) {
            String s1 = "hello";
            String s2 = "hello";
            String s3 = new String("hello");
            System.out.println(s1 == s2); // true
            System.out.println(s1 == s3); // false
    }
}
